﻿<%@page import="java.net.URLDecoder"%>
<%@page import="com.mysql.jdbc.StringUtils"%>
<%@page import="com.hhit.collaborative_learning.utils.Utils"%>
<%@page import="com.hhit.collaborative_learning.entity.Blog"%>
<%@page import="com.hhit.collaborative_learning.learning.StoreData"%>
<%@page
	import="com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
	
	String blogIdstr=request.getParameter("blogId");
	String userIdstr=request.getParameter("userId");
	int blogId=Integer.parseInt(blogIdstr);
	int userId=Integer.parseInt(userIdstr);
	PublicDaoImplMySql dao=new PublicDaoImplMySql();
	request.setAttribute("user", dao.getUserInfo(userId));
	HashMap<String, Object> blogMap=dao.getBlogById(blogId);
	Blog blog=(Blog)blogMap.get("blog");
	request.setAttribute("blogMap", blogMap);
	HashMap<String, Object> map=StoreData.getUserRankList(userId);
	request.setAttribute("rankMap", map);
	request.setAttribute("userId", userIdstr);
	String dig=URLDecoder.decode(Utils.getCookieValue("digged", request), "utf-8");
	if(!StringUtils.isNullOrEmpty(dig)){
		String[] digs=dig.split(",");
		for(String d:digs){
			if(d.equals(blogIdstr)){
				request.setAttribute("hasDig", "1");
				break;
			}
		}
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<script type="text/javascript" src="<%=basePath%>js/tracking.js"
	charset="utf-8"></script>
<script id="allmobilize" charset="utf-8"
	src="<%=basePath%>js/allmobilize.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="<%=basePath%>js/jquery.js" type="text/javascript"></script>
<script src="<%=basePath%>js/jquery.cookie.js" type="text/javascript"></script>
<!--new top-->

<link rel="stylesheet" href="<%=basePath%>css/index.css">
<!--new top-->

<link rel="Stylesheet" type="text/css"
	href="<%=basePath%>css/style.css" />
<link type="text/css" rel="stylesheet" href="<%=basePath%>css/blue.css" />
<link type="text/css" rel="stylesheet" href="<%=basePath%>css/common.css" />



</head>
<body>
	<div id="container">
		<div id="header">
			<div class="header">
				<div id="blog_title">
					<h2>
						<a href="http://blog.csdn.net/<%=userId%>">${requestScope.user.userNickName}</a>
					</h2>
					<h3>一个人的喜欢就是把自己对偶然间闪过的念想坚持，直到它变成一种习惯</h3>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
		<div id="navigator">
			<div class="navigator_bg"></div>
		</div>
		<script type="text/javascript">
			var username = <%=userIdstr%>;
			var _blogger = username;
			var blog_address = "http://blog.csdn.net/xiahouzuoxin";
			var static_host = "<%=basePath%>";
			var currentUserName = $.cookie("userId");
			
			function login(e,type){
				var href=top.location.href.substring(7).split("/");
				var link=encodeURIComponent(href[2]+"/"+href[3]);
				if(type==1){
					$(e).attr("href","<%=basePath %>login.jsp?link="+link);
				}else{
					$(e).attr("href","<%=basePath %>register.jsp?link="+link);
				}
			}
			window.onload=function(){
				var id=$.cookie("cl_readNum_Ids");
				id=id||'';
				var ids=id.split(",");
				if(ids.contain('<%=blogIdstr%>')){
				}else{
					$.post("<%=basePath%>ManageBlogServlrt",{action:7,blogId:<%=blogIdstr%>},function(data,status){
						if(data=='true'){
							ids.push(<%=blogId%>);
							$.cookie("cl_readNum_Ids", ids.join(),{expires: 30,path:"/"});
						}
					});
				}
			};
		</script>

		<div id="body">
			<div id="main">
				<div class="main">


					<link href="<%=basePath%>css/comment1.css" type="text/css"
						rel="stylesheet" />
					<link href="<%=basePath%>css/style1.css" type="text/css"
						rel="stylesheet" />
					<script language='JavaScript' type='text/javascript'
						src='<%=basePath%>js/jquery.cookie.js'></script>
<!-- 					<script type="text/javascript" src="<%=basePath%>js/main.js"></script> -->


					<link rel="stylesheet" href="<%=basePath%>css/markdown_views.css" />

					<div id="article_details" class="details">
						<div class="article_title">
							<c:choose>
								<c:when test="${requestScope.blogMap['blog']['type']==1}">
									<span class="ico ico_type_Original"></span>
								</c:when>
								<c:when test="${requestScope.blogMap['blog']['type']==2}">
									<span class="ico ico_type_Repost"></span>
								</c:when>
								<c:when test="${requestScope.blogMap['blog']['type']==3}">
									<span class="ico ico_type_Translated"></span>
								</c:when>
							</c:choose>
							<h1>
								<span class="link_title"><a
									href="<%=basePath%>learning/article.jsp?blogId=<%=blogId%>&userId=<%=userId%>">${requestScope.blogMap['blog']['blogName']}
									<c:if test="${requestScope.blogMap['blog']['isDelete'] eq 1}"><font color="red">[已删除]</font>
									</c:if><c:if test="${requestScope.blogMap['blog']['isDelete'] eq 2}"><font color="red">[草稿]</font>
									</c:if>
									</a></span>
							</h1>
						</div>

						<div class="article_manage">
							<span class="link_categories"> 分类： <a
								href="<%=basePath%>GetBlogServlet?type=${requestScope.blogMap['blog']['category']}">${requestScope.blogMap['blog']['category_CN']}</a>
							</span> <span class="link_postdate">${requestScope.blogMap['blog']['time']}</span> <span
								class="link_view" title="阅读次数">${requestScope.blogMap['blog']['readNum']}人阅读</span> <span
								class="link_comments" title="评论次数"><a href="#comments"
								onclick="">评论</a>(${requestScope.blogMap['blog']['commentNum']})</span>
							<span class="link_collect"><a href="javascript:void(0);"
								onclick=""
								title="收藏">收藏</a></span>
								<c:choose>
									<c:when test="${cookie.userId.value eq null || requestScope.userId ne cookie.userId.value}">
<!-- 									 <span class="link_report"><a -->
<!-- 									href="#report" -->
<!-- 									onclick="" -->
<!-- 									title="举报">举报</a></span> -->
									</c:when>
									<c:otherwise>
										<c:if test="${requestScope.blogMap['blog']['isDelete'] ne 1}">
										 <span class="link_report"><a
										href="<%=basePath %>learning/postedit.jsp?blogId=<%=blogId %>"
										onclick=""
										title="编辑">编辑</a></c:if></span>
									</c:otherwise>
								</c:choose>
								

						</div>

						<div id="article_content" class="article_content">
						${requestScope.blogMap['blog']['blogContent']}
						</div>
						<ul class="article_next_prev">
							<c:if test="${requestScope.blogMap['previousBlog'] ne null }">
								<li class="prev_article"><span
									onclick="top.location.href='<%=basePath%>learning/article.jsp?blogId=${requestScope.blogMap['previousBlog']['blogId']}&userId=<%=userId %>&blogName=${requestScope.blogMap['previousBlog']['blogName']}';">上一篇</span><a target="_top"
									href="<%=basePath%>learning/article.jsp?blogId=${requestScope.blogMap['previousBlog']['blogId']}&userId=<%=userId %>&blogName=${requestScope.blogMap['previousBlog']['blogName']}"
									onclick="">${requestScope.blogMap['previousBlog']['blogName']}</a></li>
							</c:if>
							<c:if test="${requestScope.blogMap['nextBlog'] ne null }">
								<li class="next_article"><span
									onclick="top.location.href='<%=basePath%>learning/article.jsp?blogId=${requestScope.blogMap['nextBlog']['blogId']}&userId=<%=userId %>&blogName=${requestScope.blogMap['nextBlog']['blogName']}';">下一篇</span><a target="_top"
									href="<%=basePath%>learning/article.jsp?blogId=${requestScope.blogMap['nextBlog']['blogId']}&userId=<%=userId %>&blogName=${requestScope.blogMap['nextBlog']['blogName']}">${requestScope.blogMap['nextBlog']['blogName']}</a></li>
							</c:if>
						</ul>
						<c:if test="${cookie.userId.value ne requestScope.userId && requestScope.blogMap['blog']['isDelete'] eq 0}">
						<div id="digg" ArticleId="44861023">
							<dl id="btnDigg" 
							<c:choose>
								<c:when test="${requestScope.hasDig eq '1'}">
									class="digg digg_disable"
								</c:when>
								<c:otherwise>
									class="digg digg_enable" onclick="dig(this,'up')"
								</c:otherwise>
							</c:choose>
							>
								<dt>顶</dt>
								<dd>${requestScope.blogMap['blog']['goodNum']}</dd>
							</dl>
							<dl id="btnBury" 
								<c:choose>
									<c:when test="${requestScope.hasDig eq '1'}">
										class="digg digg_disable"
									</c:when>
									<c:otherwise>
										class="digg digg_enable" onclick="dig(this,'cai')"
									</c:otherwise>
								</c:choose>
							 >
								<dt>踩</dt>
								<dd>${requestScope.blogMap['blog']['badNum']}</dd>
							</dl>
						</div>
						</c:if>
					</div>
			<script type="text/javascript">
				function dig(e,action){
					var username = $.cookie("userId");
					if (!username) {
			            if (confirm("您的操作必须登录，是否登录？")) {
			            	var links=top.location.href.substring(7).split("/");
			                top.location.href = basePath+"login.jsp?link="+encodeURIComponent(links[2]+"/"+links[3]);
			                return false;
			            }
			            return false;
			        }
					$.get("<%=basePath%>DiggedServlet?blogId=" + <%=blogId%> + "&userId=" + username + "&action=" + action,function(data,status){
						if(data){
							var num=$(e).children("dd").text();
							$(e).children("dd").text(parseInt(num)+1);
							var cookieval = $.cookie("digged");
						    if (cookieval) {
						        var diggeds = cookieval.split(",");
						        diggeds.push(<%=blogId%>);
						        $.cookie("digged", diggeds.join(),{path:"/"});
						    }
							$("#btnDigg").attr("class","digg digg_disable");
							$("#btnDigg").attr("onclick","");
							$("#btnBury").attr("class","digg digg_disable");
							$("#btnBury").attr("onclick","");
						}
					});
				}
			</script>
					<style>
.blog-ass-articl dd {
	color: #369;
	width: 99%; /*修改行*/
	float: left;
	overflow: hidden;
	font: normal normal 12px/23px "SimSun";
	height: 23px;
	margin: 0;
	padding: 0 0 0 10px;
	margin-right: 30px;
	background: url(../css/images/blog-dot-red3.gif) no-repeat 0 10px;
}
</style>

<!-- 					<dl class="blog-ass-articl tracking-ad" data-mod="popu_36" -->
<!-- 						id="res-relatived" style="height:  160px;"> -->
<!-- 						<dt> -->
<!-- 							<span>猜你在找</span> -->
<!-- 						</dt> -->

<!-- 						<div id="res" style="width: 42%;float: left;margin-right: 30px;"></div> -->

<!-- 						<div id="adCollege" style="width: 42%;float: left;"> -->
<!-- 							<dd> -->
<!-- 								<a href="http://edu.csdn.net/course/detail/602" -->
<!-- 									title="【精品课程】PHP面向对象设计模式" strategy="SearchAlgorithm" -->
<!-- 									target="_blank">【精品课程】PHP面向对象设计模式</a> -->
<!-- 							</dd> -->
<!-- 							<dd> -->
<!-- 								<a href="http://edu.csdn.net/course/detail/607" -->
<!-- 									title="【精品课程】U3D实时阴影绘制及Shader解决方案" strategy="SearchAlgorithm" -->
<!-- 									target="_blank">【精品课程】U3D实时阴影绘制及Shader解决方案</a> -->
<!-- 							</dd> -->
<!-- 							<dd> -->
<!-- 								<a href="http://edu.csdn.net/course/detail/604" -->
<!-- 									title="【精品课程】开发人员需要掌握的HTML和CSS知识" strategy="SearchAlgorithm" -->
<!-- 									target="_blank">【精品课程】开发人员需要掌握的HTML和CSS知识</a> -->
<!-- 							</dd> -->
<!-- 							<dd> -->
<!-- 								<a href="http://edu.csdn.net/course/detail/597" -->
<!-- 									title="【精品课程】思科路由交换CCIEv5.0最新专题课程组播技术" -->
<!-- 									strategy="SearchAlgorithm" target="_blank">【精品课程】思科路由交换CCIEv5.0最新专题课程组播技术</a> -->
<!-- 							</dd> -->
<!-- 							<dd> -->
<!-- 								<a href="http://edu.csdn.net/course/detail/566" -->
<!-- 									title="【精品课程】C语言基础视频教程" strategy="SearchAlgorithm" -->
<!-- 									target="_blank">【精品课程】C语言基础视频教程</a> -->
<!-- 							</dd> -->
<!-- 						</div> -->

<!-- 					</dl> -->
					<div class="comment_class">
						<div id="comment_title" class="panel_head">
							<span class="see_comment">查看评论</span><a name="comments"></a>
						</div>
						<div id="comment_list"></div>
						<div id="comment_bar"></div>
						<div id="comment_form"></div>

						<div class="announce">
							* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场<a name="reply"></a><a
								name="quote"></a>
						</div>
					</div>

					<script type="text/javascript">
						var fileName = <%=blogIdstr%>;
						var commentscount = <%=blog.commentNum%>;
						var canComment = <%=blog.canComment%>;
					</script>
					<script type="text/javascript" src="<%=basePath%>js/comment.js"></script>
					<div id="ad_bot"></div>
					<div id="report_dialog"></div>

					<script type="text/javascript">
						$(function() {
							$("#ad_frm_0").height("90px");

							setTimeout(function() {
								$("#ad_frm_2").height("200px");
							}, 1000);

						});
					</script>

					<div id="pop_win"
						style="display:none ;position: absolute; z-index: 10000; border: 1px solid rgb(220, 220, 220); top: 222.5px; left: 630px; opacity: 1; background: none 0px 0px repeat scroll rgb(255, 255, 255);">

					</div>
					<div id="popup_mask"></div>
					<style>
#popup_mask {
	position: absolute;
	width: 100%;
	height: 100%;
	background: #000;
	z-index: 9999;
	left: 0px;
	top: 0px;
	opacity: 0.3;
	filter: alpha(opacity = 30);
	display: none;
}
</style>




					<div class="clear"></div>
				</div>

			</div>
			<div id="side">
				<div class="side">
					<div id="panel_Profile" class="panel">
						<ul class="panel_head">
							<span>个人资料</span>
						</ul>
						<ul class="panel_body profile">
							<div id="blog_userface">
								<a href="<%=basePath %>my.jsp?userId=${requestScope.user.userId}" target="_blank"> <img
									src="<%=basePath %>userIcons/${requestScope.user.userIcon}"
									title="访问我的空间" style="max-width:90%" />
								</a> <br /> <span><a href="<%=basePath %>my.jsp?userId=${requestScope.user.userId}"
									class="user_name" target="_blank">${requestScope.user.userNickName}</a></span>
							</div>
							<div class="interact">
								<a href="javascript:void(0);" class="attent"
									id="span_add_follow" title="[加关注]"
									onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_guanzhu'])"></a>

								<!-- 								<a href="javascript:void(0);" class="letter" title="[发私信]" -->
								<!-- 									onclick="window.open('http://msg.csdn.net/letters/model?receiver=xiahouzuoxin','_blank','height=350,width=700');_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_sixin'])"></a> -->
							</div>
							<div id="blog_medal">
								<div class="ico_expert" title="认证专家"
									style="width:54px;height:60px;background:url('http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/bokezhuanjiamiddle.png') no-repeat"></div>
								<div id="bms_box">
<!-- 									<a target="_blank"> <img -->
<!-- 										src="http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/zhuanlandaren.png" -->
<!-- 										onmouseover="m_over_m(this,2)" onmouseout="m_out_m()" alt="2"> -->
<!-- 									</a> <a target="_blank"> <img -->
<!-- 										src="http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/chizhiyiheng.png" -->
<!-- 										onmouseover="m_over_m(this,4)" onmouseout="m_out_m()" alt="1"> -->
<!-- 									</a> -->
								</div>
							</div>
							<ul id="blog_rank">
								<li>访问：<span>${requestScope.user.totalReadNum}次</span></li>
								<li>积分：<span>${requestScope.user.userPoint}</span>
								</li>
<!-- 								<li>等级： <span -->
<!-- 									style="position:relative;display:inline-block;z-index:1"> -->
<!-- 										<img -->
<!-- 										src="http://c.csdnimg.cn/jifen/images/xunzhang/jianzhang/blog6.png" -->
<!-- 										alt="" style="vertical-align: middle;" id="leveImg"> -->
<!-- 										<div id="smallTittle" -->
<!-- 											style=" position: absolute;  left: -24px;  top: 25px;  text-align: center;  width: 101px;  height: 32px;  background-color: #fff;  line-height: 32px;  border: 2px #DDDDDD solid;  box-shadow: 0px 2px 2px rgba (0,0,0,0.1);  display: none;   z-index: 999;"> -->
<!-- 											<div -->
<!-- 												style="left: 42%;  top: -8px;  position: absolute;  width: 0;  height: 0;  border-left: 10px solid transparent;  border-right: 10px solid transparent;  border-bottom: 8px solid #EAEAEA;"></div> -->
<!-- 											积分：5281 -->
<!-- 										</div> -->
<!-- 								</span> -->
<!-- 								</li> -->
								<li>排名：<span>第${requestScope.user.ranking}名</span></li>
							</ul>
							<ul id="blog_statistics">
								<li>原创：<span>${requestScope.user.originalNum}篇</span></li>
								<li>转载：<span>${requestScope.user.repostNum}篇</span></li>
								<li>译文：<span>${requestScope.user.translatedNum}篇</span></li>
								<li>评论：<span>${requestScope.user.totalCommentNum}条</span></li>
							</ul>
						</ul>
					</div>

					<div id="hotarticls" class="panel">
						<ul class="panel_head">
							<span> 阅读排行 </span>
						</ul>

						<ul class="panel_body itemlist">
							<c:forEach items="${requestScope.rankMap['readRank'] }" var="rank">
								<li><a href="main_article.jsp?blogId=${rank.blogId}&userId=<%=userId %>" target="_self"
								title="${rank.blogName }">${rank.blogName }</a><span>(${rank.readNum })</span></li>
							</c:forEach>
						</ul>
					</div>

					<div id="hotarticls2" class="panel">
						<ul class="panel_head">
							<span>评论排行</span>
						</ul>
						<ul class="panel_body itemlist">
						<c:forEach items="${requestScope.rankMap['commentRank'] }" var="rank">
							<li><a href="main_article.jsp?blogId=${rank.blogId}&userId=<%=userId %>" target="_self"
							title="${rank.blogName }">${rank.blogName }</a><span>(${rank.commentNum })</span></li>
						</c:forEach>
						</ul>
					</div>

					<c:if test="${!empty requestScope.rankMap['recommentList']}">
						<div id="commend" class="panel">
							<ul class="panel_head">
								<span>推荐文章</span>
							</ul>
							<ul class="panel_body itemlist">
								<c:forEach items="${requestScope.rankMap['recommentList'] }" var="rank">
									<li><a href="main_article.jsp?blogId=${rank.blogId}&userId=<%=userId %>" target="_self"
									title="${rank.blogName }">${rank.blogName }</a></li>
								</c:forEach>
							</ul>
						</div>
					</c:if>

				</div>

				<div class="clear"></div>
			</div>

			<div class="clear"></div>
		</div>


<!-- 		<script type="text/javascript" src="<%=basePath%>js/cnick.js"></script> -->
		<script type="text/javascript" src="<%=basePath%>js/newblog.min.js"></script>
<!-- 		<script type="text/javascript"> -->
<!-- 			$(function() { -->
<!-- 				function __get_code_toolbar(snippet_id) { -->
<!-- 					return $("<a href='https://code.csdn.net/snippets/" -->
<!--                     + snippet_id -->
<!--                     + "' target='_blank' title='在CODE上查看代码片' style='text-indent:0;'><img src='https://code.csdn.net/assets/CODE_ico.png' width=12 height=12 alt='在CODE上查看代码片' style='position:relative;top:1px;left:2px;'/></a>" -->
<!-- 							+ "<a href='https://code.csdn.net/snippets/" -->
<!--                     + snippet_id -->
<!--                     + "/fork' target='_blank' title='派生到我的代码片'  style='text-indent:0;'><img src='https://code.csdn.net/assets/ico_fork.svg' width=12 height=12 alt='派生到我的代码片' style='position:relative;top:2px;left:2px;'/></a>"); -->
<!-- 				} -->

<!-- 				$("[code_snippet_id]").each( -->
<!-- 						function() { -->
<!-- 							__s_id = $(this).attr("code_snippet_id"); -->
<!-- 							if (__s_id != null && __s_id != "" && __s_id != 0 -->
<!-- 									&& parseInt(__s_id) > 70020) { -->
<!-- 								__code_tool = __get_code_toolbar(__s_id); -->
<!-- 								$(this).prev().find(".tools").append( -->
<!-- 										__code_tool); -->
<!-- 							} -->
<!-- 						}); -->
<!-- 			}); -->
<!-- 		</script> -->

		<link href="<%=basePath%>css/ask_float_block.css" type="text/css"
			rel="stylesheet" />
		<script type='text/javascript'>
(function(){
$(function(){
	var back_top_value =Math.ceil(document.documentElement.clientHeight *0.65);
	var float_ask_img="<div data-mod='popu_64' class='tracking-ad' chg-blk='0' ><a id='com-d-top-a'  style='top:"+back_top_value+"px' title='返回顶部' onclick='' ></a> </div>";
	$("body").append(float_ask_img);
	
	var d_top = $('#com-d-top-a');

        $(document).scroll(function(){
            var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
            if (scrTop > 500)
            {
                d_top.show();
            } else
            {
                d_top.hide();
            }

        })
        $('#com-d-top-a').click(function ()
        {
            scrollTo(0, 0);
            this.blur();
            return false;
        });
});
})();
</script>

</body>
</html>

